App.controller("activityEvaluationCtrl",function($scope, $rootScope, $location, $http, $compile, $stateParams, $timeout, path, publicService) {
	
	$scope.search = {};		//搜索参数
	var alertModel = {};	//alert模态框
	
	
	
	//表格对象
	$scope.gridOptions = {
			dataSource : {
				transport : {
					read : {
						url : path+"/server/selectCommentActivityPage",
						type : 'POST',
						dataType : "json",
						contentType : "application/json"
					},
					parameterMap : function(options, operation) {
						if (operation == "read") {
							var parameter = {
								page : options.page, //当前页
								pageSize : options.pageSize,
								param:{
									activity_name:$scope.search.activity_name,  //活动名称
									customer_name:$scope.search.consumer_name,  //消费者姓名
									phone:$scope.search.phone,  //联系方式
									shop_name:$scope.search.belong_commercial,  //所属商户
							
									start_time:$('#comment_startTime').val(),  //评论日期（始）
									end_time:$('#comment_endTime').val(),  //评论日期（终）
									guide:$scope.search.exclusive_guide,  //专属导购
								}
							};
							console.log('查询参数',parameter);
							return kendo.stringify(parameter);
						}
					},
				},
				pageSize : 10,
				serverPaging : true,
				serverSorting: true,
				schema : {
					data : function(d) {
						return d.data;
					},
					total : function(d) {
						return d.total; //总条数
					}
				},
			},
			pageable : {  //分页
				pageSizes: [10, 20, 50, 100],  //每页显示记录数
			  },  
			sortable: {   //排序
				//allowUnsort: false,  //允许无序
			    mode: "multiple"     //排序模式：single，multiple
			  },
			editable: false,  //true：单个编辑；popup：弹出新页面编辑
			dataBound: function () {   //序号
		        var rows = this.items();
		        var page = this.pager.page() - 1;
		        var pagesize = this.pager.pageSize();
		        $(rows).each(function () {
		            var index = $(this).index() + 1 + page * pagesize;
		            var rowLabel = $(this).find(".row-number");
		            $(rowLabel).html(index);
		        });
		    },
			columns : [
					{    
						title : "序号",
						field : "id", 
						width : "50px",
						template:"<span class='row-number subTitle'></span>"
					},
					{
						field : "activity_name",         
						title : "活动名称",     
						width : "100px"
					},
					{
						field : "customer_name",         
						title : "消费者姓名",     
						width : "100px"
					},
					{
						field : "phone",         
						title : "联系方式",     
						width : "100px"
					},
					{
						field : "content",         
						title : "评价内容",     
						width : "100px"
					},
					{
						field : "create_time",         
						title : "评价日期",     
						width : "100px"
					},
					{
						field : "shop_name",         
						title : "所属专卖店",     
						width : "100px"
					},
					{
						field : "guide",         
						title : "专属顾问",     
						width : "100px"
					}
	
			]
	};
	
	//查询
	$scope.search = function(){
		$scope.grid.dataSource.page(1);
	}
	
	//全选，取消
	$scope.chooseAll = function(className,flag){
		publicService.chooseAllByClassName(className,flag);
	}
	
	//筛选导出
	$scope.downloadBySearch = function(){
		
	}
	
	//选中导出
	$scope.downloadByChoose = function(){
		
	}
	
	
	

	publicService.initDateTime("comment_startTime");	//评价日期（始）
	publicService.initDateTime("comment_endTime");		//评价日期（止）
	
	

	
	
	
	
	
});